home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / tlxutl10.zip / RANDPASS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-25  |  3KB  |  123 lines

  1. Program RandPass;
  2. { This is a Turbo Pascal 5.5 program designed to read a Telix 3.xx phone
  3. directory file and create random passwords }
  4. {$B-}
  5.  
  6. Type
  7.     Entries = Record
  8.                 Name : Array [0..24] of Char;
  9.                 Number : Array [0..16] of Char;
  10.                 Baud, Parity, Data, Stop : Byte;
  11.                 Script : Array [0..11] of Char;
  12.                 Lastcall : Array [0..5] of Char;
  13.                 TotCalls : Word;
  14.                 Terminal : Byte;
  15.                 Protocol : Char;
  16.                 Toggles, fill1, fill2, DPrefNum : Byte;
  17.                 Password : Array [0..13] of Char;
  18.             End;
  19.     Header = Record
  20.                 Id : Longint;
  21.                 ddf_vers, num_entries : Integer;
  22.                 Pencrypted : Byte;
  23.                 Spare : Array [0..54] of Byte;
  24.             End;
  25.  
  26. Var
  27.     PDir : File;
  28.     Report : Text;
  29.     Reporting : Boolean;
  30.     FName : String;
  31.     Choice : Char;
  32.     Entry : Entries;
  33.     head : Header;
  34.     Count : Byte;
  35.     EntryNo : Word;
  36.  
  37. Label
  38.     Over;
  39.  
  40. Function Padd (str : String; num : byte):String;
  41.  
  42. Var
  43.     Result : String;
  44.  
  45. Begin
  46.     FillChar (Result,num-ord(str[0])+1,' ');
  47.     Result[0] := Chr(num-ord(str[0]));
  48.     Result := Concat(str,result);
  49.     Padd := Result;
  50. End;
  51.  
  52. Function CtoPas (Var str; size : byte):string;
  53.  
  54. Type
  55.     CString = Array [1..256] of Char;
  56.  
  57. Var
  58.     Count : Byte;
  59.     Result : String;
  60.  
  61. Begin
  62.     Count := 1;
  63.     While (CString(str)[Count] <> #0) and (Count < Size) Do
  64.         Begin
  65.             Result[Count] := CString(str)[Count];
  66.             Inc (Count);
  67.         End;
  68.     Result[0] := Chr(Count-1);
  69.     CtoPas := Result;
  70. End;
  71.  
  72. Begin
  73.     Randomize;
  74.     Write ('Enter filename:   ');
  75.     ReadLn (FName);
  76.  
  77.     Assign (PDir,FName);
  78.     {$I-}
  79.     Reset (PDir,1);
  80.     {$I+}
  81.     Write ('Do you want reporting to None,Screen,Printer,File? (N/S/P/F)  ');
  82.     ReadLn (Choice);
  83.     Reporting := True;
  84.     Case UpCase(Choice) Of
  85.     'S' : Assign (Report,'');
  86.     'P' : Assign (Report,'PRN');
  87.     'F' : Begin
  88.                 Write ('Enter report file name:   ');
  89.                 ReadLn (FName);
  90.                 Assign (Report,FName);
  91.             End;
  92.     Else
  93.         Reporting := False;
  94.     End;
  95.     If Reporting Then Rewrite (Report);
  96.  
  97.     If IOResult <> 0 Then
  98.         Begin
  99.             WriteLn ('Error! File not found');
  100.             Goto over;
  101.         End;
  102.     Seek(PDir,0);
  103.     BlockRead (PDir,Head,SizeOf(Head));
  104.     For EntryNo := 0 To head.num_entries-1 Do
  105.         Begin
  106.             Seek(PDir,SizeOf(Head)+EntryNo*SizeOf(Entry));
  107.             BlockRead (PDir,Entry,SizeOf(Entry));
  108.             If Entry.Password[1] = #0 Then
  109.                 For Count := 0 to 7 Do
  110.                     Entry.Password[Count] := Chr(Random(26)+65);
  111.             Seek(PDir,SizeOf(Head)+EntryNo*SizeOf(Entry));
  112.             BlockWrite (PDir,Entry,SizeOf(Entry));
  113.             If Reporting Then
  114.                 With Entry Do
  115.                     WriteLn (Report,Padd(CtoPas(Name,SizeOf(Name)),SizeOf(Name)),
  116.                             CToPas(Password,SizeOf(Password)));
  117.  
  118.         End;
  119.  
  120.     Close (PDir);
  121.     If Reporting Then Close (Report);
  122.     over:
  123. End.